package Aleehot100;

import java.lang.reflect.Array;
import java.util.Arrays;

/**
 * ClassName: c098
 * Package: Aleehot100
 * Description:75. 颜色分类
 *
 * @Author BCXJ
 * @Create 2025/9/16 07:46
 * @Version 1.0
 * @Since 1.0
 */
public class c098 {
    public static void main(String[] args) {
        int[] arr = {2,0,2,1,1,0};
        sortColors(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void sortColors(int[] nums) {
        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] == 0){count1 ++;}
            if(nums[i] == 1){count2 ++;}
            if(nums[i] == 2){count3 ++;}
        }

        int index = 0;
        for (int i = 0; i < count1; i++) {
            nums[index++] = 0;
        }
        for (int i = 0; i < count2; i++) {
            nums[index++] = 1;
        }
        for (int i = 0; i < count3; i++) {
            nums[index++] = 2;
        }

    }

}
